<template>
  <div class="pageheader">
    <h3 class="item-title" :style="'color:'+bg">
      <!-- <slot></slot> -->
      <template v-for='(item,index) in urlList'>
         <router-link :to="item.menu_url" :key="index" replace>
         <b v-if="index!=0" >&gt;</b>
         {{item.menu_name}}
         </router-link>
      </template>
      <!-- <router-link :to="item in urlList" replace>{{item.menu_name}}</router-link> -->
    </h3>
    <div v-if="isShow" style="float: right;">
      <el-button type="primary" size="small" class="el-icon-plus" @click="add">新增</el-button>
    </div>
  </div>
</template>
<style lang="scss">
 .pageheader { 
  	background: #fff;
	 padding: 25px 35px 16px ;
	.el-button--primary{
    color: #545deb;
    background-color: #eef2ff;
		border-color: #bbccff;
		border-radius: 2px;
		padding: 8px 27px 8px 23px;
	 
		margin-top: -50%;
		font-size: 12px;
		&::before{
			vertical-align: middle;
		}
		span{
			margin-left: 5px;
			font-size: 16px;
		
		}
  }
  .el-button--primary:hover{
		color: #fff;
    background-color: #545deb;

  }
  .el-button--primary:focus{
		color: #fff;
    background-color: #545deb;
  }
	.item-title {
			display: inline-block;
			width: 50%;
			
			line-height: 1;
			font-size: 16px;
			font-weight: 500;
		}
  }
</style>
<script>
import config from "@/config/config.js";
export default {
   data() {
      return {
         bg: "",
         title: "",
         urlList:[]
      };
   },
   props: ['event','isShow'],
   components: {},
   created() {},
   mounted() {
      this.bg = localStorage.UserThemeColor;
      var name=this.$route.name;
      var urlList=[];
      var isTrue="";
      try {
         var menu=JSON.parse(sessionStorage.menu);
         let forChildren=function(list){
            if(list && list.forEach){
               for (let i = 0; i < list.length; i++) {
                  const ele2 = list[i];
                  // console.log(ele2,ele2.menu_url,name)
                  if(ele2.menu_url==name){
                     urlList.push(ele2);
                     return ele2.menu_name
                  }else if(ele2.children && ele2.children.length>0){
                     var str=forChildren(ele2.children)
                     if(str){
                        urlList.push(ele2)
                        return isTrue+=">"+str
                     }
                  }
               }
               return isTrue
            }
         }
         forChildren(menu)
         // console.log(urlList)
         this.urlList=urlList.reverse()
         // this.title=con
      } catch (error) { 
         console.error("没有加载菜单",error);
      }
   },
   methods: {
      add() {
         this.$Bus.$emit(this.event, true);
      }
   },
   watch: {}
};
</script>
